This page last changed on Sep 24, 2007 by jdeolive.

LESSON 2: Adding Data

Objective:
In this tutorial you will learn how to configure GeoServer to publish with raster and vector data as a 2d map using the Web Map Service Protocol.

Loading and Configuring a Shapefile

  1. Start up GeoServer by going to the Start menu.
  2. Use your web browser and navigate to:
    http://localhost:8080/geoserver/welcome.do

Step 1: Log In

  1. From the welcome page select the Config link located near the top left of the page:
  2. You will be asked to log in. The default username is admin an default passowrd is geoserver:
  3. We recommend checking the box marked 'Remember my login on this computer', which makes it so you don't have to retype the password when you restart GeoServer.
  4. Click Submit. This will take you back to the welcome page.

Step 2: Create a Data Store

  1. Click on Config again and you will be taken to the main config page.
  2. Select the Data link:
  3. Select the DataStores link:

    You are now in the data store page. Data stores are essentially a location where data lives. It can be a shapefile or database location.
  4. Select the New link:
  5. On the 'Create New Data Store' page:
    1. Select Shapefile from the drop down list labeled DataStore Description.
    2. Enter the text streams into the text field labeled DataStore ID.
    3. Hit the New button.
      This takes you to the data store editor. Here we need to say where our shapefile is.
  6. On the DataStore Editor page:
    1. enter the path of your streams shapefile (streams.shp).
      We have included it in your GeoServer install under (geoserver home)/data_dir/data/sf/streams.shp Which means the url will be:

      In GeoServer if you fill out the url field starting with file:data then it makes it relative to your data_dir. You can also enter the complete file url, according to the conventions of your file system.

    2. Set the Namespace to topp.
    3. Leave the Description text area blank.
    4. Hit Submit.
      #This will lead you to the feature type configuration page (it happens every time a datastore has a single feature type in it, that is, typically with shapefiles).

Step 3: Create a Feature Type for Your Data

Feature Types are the different sets of data that are in your data location. For a shapefile there will only be one, but if your DataStore was a database, you might have several data sets to choose from. Each one of these is a Feature Type. With Shapefiles hitting submit on the DataStore editor will automatically forward you to the FeatureType Editor. If you are working with a database you will have to select your FeatureType from the menu at Config -> Data -> FeatureType and hit New. You can also navigate to your existing FeatureTypes from that page.

  1. You should now be at the FeatureType editor page.
    1. From the drop down list labeled Style, select simple_stream. This will determine how your features will be rendered. You can also play with the very basic SLD creator - just hit the button 'Create New SLD', and then after you are done select the newly created streams_style from the Style drop down.
    2. Next to the text field labeled SRS hit the 'Lookup' button. This will figure out the Projection that your dataset is in. This depends on having a .prj file as part of your shapefile.
    3. Hit the Generate button. This will generate the bounding box of the dataset. If it comes up 'UNKNOWN' then enter 26713 for this dataset. The code usually does the look up fine, but sometimes you have to know the EPSG code if it fails.
    4. Now scroll down to the bottom and hit Submit.
  2. Finally, hit the Apply button on the left of the screen. Then hit the Save button to save all of the changes to disk.

Step 4: Preview Your Data

Lets head over to the Demo page of GeoServer and preview our data.
Open up this URL in your browser:
http://localhost:8080/geoserver/mapPreview.do
Or just navigate to the welcome page, and click on Demo then on Map Preview

Locate your topp:streams layer, then click on the Preview link to the right of it. After a few seconds you should see a your streams dataset!

Step 5: Loading and Configuring a GeoTiff

Next we want to do the same sort of configuration, but in this case for a GeoTiff instead of a Shapefile. A GeoTiff is a raster, so the configuration path is slightly different, but very similar. Try to add the 'dem.tif' file, but note that you go to CoverageStores and Coverages instead of DataStores and FeatureTypes. If you get stuck you can check out the tutorial on adding a GeoTiff.

  1. Go to Config, Data, CoverageStores
  2. New, select "Tagged image file format with geometry information" (GeoTiff), call the coveragestore "dem"
  3. Configure the GeoTiff file just as you configured the shapefile, but use "file:data/sf/dem.tif"
  4. Hit Submit if there are no path errors you'll get to the coverage configuration page, where you just have to hit submit again (style, srs and bounding box are already filled in for you)
  5. As usual, hit apply to store the new configuration
  6. Go to the preview and check the new layer (topp:dem)

Extra Credit

If you've finished these tasks early, there are a few things you can try out while everyone else catches up.

  1. PostGIS layers - use the postgis database already installed and get it served by GeoServer
    1. Start up PostGIS (should be in the Start Menu, 'Start Service' under PostgreSQL 8.2).
    2. When you add a new datastore pick 'PostGIS'
    3. Use the defaults, with 'example' for the database, 'postgres' for the user and 'postgres' for the password
    4. Go to Config -> Data -> FeatureTypes -> New and select one of bc_hospitals, bc_pubs, bc_roads, bc_voting_areas - which should be there if you did things right.
    5. Fill out the rest of config as you normally would.
  2. uDig style editing. Create a thematic style in uDig, upload to GeoServer, and get it used as the default
    style. The 'soils' shapefile is a good one to do a thematic style with.
    1. Open uDig, should be under the Start Menu
    2. Find the soils shapefile, at (geoserver-install)/data_dir/data/sf/soils.shp and open it in uDig (should be able to drag and drop, or do 'import' -> 'files'
    3. Right click on the layer in the layer list on the left and select 'change style'. Select 'theme' and play with changing around the attribute, classes, breaks, and palette. When you find one you're happy with hit 'export'
    4. Go to GeoServer's web admin, Config -> Data -> Styles and upload your new style, and be sure to remember the name.
    5. Create the 'soils' featureType, in the same way you did streams above. The data should be in the same location. When you get to the style portion put in the style you uploaded.
  3. Layer Grouping - create a group of layers to be referenced as a single layer
    1. Go to the web admin console - Config -> WMS -> Contents
    2. Select 'Add New Layer-Group' button at the bottom.
    3. Fill out the basemap layers with topp:streams,topp:dem plus the PostGIS and soils layers if you did the other extra credits. The styles section you can leave blank and it will use default styles.
    4. Check your new layer in the preview to make sure they worked.

ad-login.png (image/png)
ad-login.png (image/png)
ad-config.png (image/png)
ad-data.png (image/png)
ad-streams.png (image/png)
ad-streams.png (image/png)
ad-streams.png (image/png)
ad-featureType.png (image/png)
ad-featureType.png (image/png)
ad-featureType2.png (image/png)
Document generated by Confluence on Jan 16, 2008 23:27